package com.ls.hnks.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ls.hnks.util.Result;
import com.ls.hnks.model.Todo;
import com.ls.hnks.service.TodoService;
import com.ls.hnks.mapper.TodoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 15375
* @description 针对表【tb_todo】的数据库操作Service实现
* @createDate 2023-04-02 01:11:59
*/
@Service
public class TodoServiceImpl extends ServiceImpl<TodoMapper, Todo>
    implements TodoService{

    @Autowired
    private TodoMapper todoMapper;

    @Override
    public Result getPageByUserId(String userId, Integer pageNo, Integer size) {
        Page<Todo> page = new Page<>(pageNo,size);
        QueryWrapper<Todo> todoQueryWrapper = new QueryWrapper<>();
        todoQueryWrapper.orderByDesc("Deadline");
        IPage<Todo> todoPage = this.page(page, todoQueryWrapper);
        return Result.ok(todoPage);
    }

    @Override
    public Result getListByUserAndDate(String userId, String date) {
        List<Todo> list = todoMapper.getAllByUserAndDate(userId,date);
        return Result.ok(list);
    }
}




